package com.yeung.exam;

import java.util.Scanner;

/**
 * 将一个整整 拆分成n个数, 使得最后的乘积最大
 */
public class 讯飞_整数N拆分求最大乘积 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(method3(n));
    }

    public static int interBreakProblem(int n) {
        if (n == 2 || n == 3)
            return n - 1;
        if (n == 4) return n;
        int result = 1;
        while (n > 4) {
            result *= 3;
            n -= 3;
        }
        return result * n;

    }

    public static int method3(int n) {
        if (n == 2 || n == 3) {
            return n - 1;
        }
        int x = n % 3;
        int y = n / 3;
        double result = 1;
        if (x == 1) {
            result = Math.pow(3, y - 1) * 4;
        } else if (x == 2) result = Math.pow(3, y) * x;
        else if (x == 0) result = Math.pow(3, y);
        return (int) result;
    }

    public static int integerBreak(int n) {
        int[] dp = new int[n + 1];
        dp[1] = 1;
        for (int i = 2; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                dp[i] = Math.max(dp[i], (Math.max(j, dp[j])) * (Math.max(i - j, dp[i - j])));
            }
        }
        return dp[n];
    }


}
